/*
获取url地址内的参数
getParameter
param:url参数名称
返回值为获取的参数值，如果没有该参数则返回一个空字符串
*/
function getParameter(param) {
    var query = window.location.search;
    var iLen = param.length;
    var iStart = query.indexOf(param);
    if (iStart == -1)
        return "";
    iStart += iLen + 1;
    var iEnd = query.indexOf("&", iStart);

    if (iEnd == -1)
        return query.substring(iStart);
    return query.substring(iStart, iEnd);
}
function isWeiXin() {
    var ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
        return true;
    } else {

        return false;
    }
}
const operateCookie = {
    setCookie: function (c_name, value, expiredays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = c_name + "=" + escape(value) +
            ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()) + "; path=/";
    },
    getCookie: function (name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg))
            return unescape(arr[2]);
        else
            return null;
    },
    delCookie: function (name) {
        var exp = new Date();
        exp.setTime(exp.getTime() + (-1 * 24 * 60 * 60 * 1000));
        var cval = getCookie(name);
        document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString() + "; path=/";
    }
}


function trackUrl() {
    setInterval(function () {
        var browseUrl = window.location.href.split("?")[0];
        $.ajax({
            url: marking.path + "/v1/lenovo/weChat/updateWaitTime.do",
            dataType: "jsonp",
            type: "post",
            data: {
                browseUrl: browseUrl,
                source: marking.userIdentify.source
            },
            success: function (data) {
                //console.log(data.errormsg);
            },
            error: function () {
                //console.log("服务器异常");
            }
        });
    }, 10000);
}
function saveShareAccessRecord() {
    var browseUrl = window.location.href;
    $.ajax({
        url: marking.path + "/v1/lenovo/weChat/saveShareAccessRecord.do",
        dataType: "jsonp",
        type: "post",
        data: {
            browseUrl: browseUrl,
            shareId: marking.userIdentify.shareId
        },
        success: function (data) {
            //console.log(data.errormsg);
        },
        error: function () {
            //console.log("服务器异常");
        }
    });
}

function shareRecord(shareType, shareId) {
    var localURL = window.location.href;
    $.ajax({
        url: smarking.globalPath + "/v1/lenovo/weChat/shareRecord.do",
        dataType: "jsonp",
        type: "post",
        data: {
            shareType: shareType,
            shareUrl: localURL,
            shareId: shareId,
        },
        success: function (data) {

        },
        error: function () {
            //console.log("服务器异常");
            //如果此处无响应8.4版本应该跳转到车主认证页面
        }
    })
}